package reflect;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

public class Test {
    public static void main(String[] args) throws NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {
        Student s = new Student("王二", 33, '男');
        System.out.println(s);



        Class cls2 = Student.class;
        Object obj1 = cls2.newInstance();
        System.out.println(obj1);

        Constructor con2 = cls2.getConstructor();
        Object ojb2 = con2.newInstance();
        System.out.println(ojb2);

        Constructor con3 = cls2.getConstructor(String.class, int.class, char.class);
        Object obj3 = con3.newInstance("李四", 25, '女');
        System.out.println(obj3);
    }
}
